﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GcmpModelInterface.h"
#include "IDbObject.h"


namespace gcmp
{
    class IDocument;
    
    class IElement;
    class IGraphicsElementShape;
    class IModelingOperation;

    class IElementModelingOperations : public IDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::IElementModelingOperations, gcmp::IDbObject);

    public:
        GCMP_MODEL_INTERFACE_EXPORT static OwnerPtr<IElementModelingOperations> CreateDefaultBehavior(IDocument* pDoc, const ElementId& ownerElementId);

        virtual IDocument* GetDocument() const = 0;
        virtual bool SetDocument(IDocument* pDocument) = 0;
        virtual ElementId GetOwnerElementId() const = 0;

        virtual Int32 AddOperation(OwnerPtr<IModelingOperation> modelingOperation) = 0;

        virtual const std::vector<const IModelingOperation*> GetModelingOperations()const = 0;

        virtual std::vector<WeakPtr<IModelingOperation>> GetModelingOperationsFW() = 0;

        virtual void Reset(Int32 initialGNodeId) = 0;

        /// \brief 执行当前接口的所有操作
        /// \param pElement   当前接口所属的Element
        /// \param pResultGraphicsElementShape 输入输出的Element Shape
        /// \return true,成功；false，失败
        virtual bool Execute(IElement* pElement, IGraphicsElementShape* pResultGraphicsElementShape) = 0;

        /// \brief element被删除，modelingOperation可以做一些后续处理工作， 比如清理与被删除element相关的历史追溯信息
        ///
        /// \param deletedElementIds   删除的element id集和
        virtual void UpdateForDeletion(const std::vector<ElementId>& deletedElementIds) = 0;

        /// \brief 设置该行为所属Element
        /// \param pOwnerElement 所属Element
        /// \return bool
        virtual bool SetOwnerElement(IElement* pOwnerElement) = 0;

        /// \brief 获得该外部对象所属Element
        /// \return const IElement* 所属Element
        virtual const IElement* GetOwnerElement() const = 0;

        /// \brief 获得该外部对象所属Element
        /// \return IElement* 所属Element
        virtual IElement* GetOwnerElement() = 0;
    };
}


